package process_demo.blocking_queue_impl;

/**
 * @author haomin
 * @date 2022/04/25 21:05
 **/
import java.util.Scanner;

public class Main2 {
    static MyArrayBlockingQueue queue = new MyArrayBlockingQueue(3);

    static class MyThread extends Thread {
        @Override
        public void run() {
            Scanner scanner = new Scanner(System.in);
            long e = scanner.nextLong();

            try {
                // 取出
                queue.take();
            } catch (InterruptedException interruptedException) {
                interruptedException.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();

        queue.put(1);
        queue.put(2);
        queue.put(3);
        queue.put(4);   // 阻塞
        System.out.println("4 被放入队列中");
    }
}